package com.wise.schedule.sample2quartz.task;

import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

@Component
@Profile("sample2")
public class ScheduleTask {
    public void doTask() {
        System.out.println("开始执行调度任务");
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
        try {
            Date startTime = sdf.parse("09:00:00");
            Date endTime = sdf.parse("12:00:00");
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            System.out.println(simpleDateFormat.format(startTime) + "_" + simpleDateFormat.format(endTime));
            if (date.after(startTime) && date.before(endTime)) {
                System.out.println("do something!");
            }
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }
}
